package common.db.io;

import common.db.io.Logger;

import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: Paskal
 * Date: May 8, 2009
 * Time: 8:18:24 PM
 * To change this template use File | Settings | File Templates.
 */
public class MyLog
{
	private static final String CORE_LOG = "c:/JavaProjects/log_Core.log";
	private static final String UI_LOG = "c:/JavaProjects/log_UI.log";

	private static Logger uiLogger;
	private static Logger coreLogger;

	private boolean logForCore = false;
	private String pack;
	public MyLog(Class clazz)
	{
		pack = clazz.getCanonicalName();
		if(!pack.contains(".ui"))
			logForCore = true;

	}

	public void debug(Object o)
	{
		String word = null;
		if(o == null)
			word = "null";
		else
			word = o.toString();
		String line = " DEBUG "+pack+" - "+word;
		if(logForCore)
			writeToCore(line);
		else
			writeToUI(line);

	}

	private static synchronized void writeToUI(String line)
	{
		if (uiLogger == null)
			uiLogger = new Logger(UI_LOG);

		uiLogger.log(line);

	}

	private static synchronized void writeToCore(String line)
	{
		if (coreLogger == null)
			coreLogger = new Logger(CORE_LOG);

		coreLogger.log(line);

	}


	}
